package com.fr.cell.core;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.io.Serializable;

public class RGridLayout
  implements LayoutManager, Serializable
{
  public static final String GridCorner = "GridCorner";
  public static final String GridColumn = "GridColumn";
  public static final String GridRow = "GridRow";
  public static final String Grid = "Grid";
  public static final String HorScrollBar = "HorScrollBar";
  public static final String VerScrollBar = "VerScrollBar";
  private Component gridCorner;
  private Component gridColumn;
  private Component gridRow;
  private Component grid;
  private Component horScrollBar;
  private Component verScrollBar;

  public void addLayoutComponent(String paramString, Component paramComponent)
  {
    if ("GridCorner".equals(paramString))
      this.gridCorner = paramComponent;
    else if ("GridColumn".equals(paramString))
      this.gridColumn = paramComponent;
    else if ("GridRow".equals(paramString))
      this.gridRow = paramComponent;
    else if ("Grid".equals(paramString))
      this.grid = paramComponent;
    else if ("HorScrollBar".equals(paramString))
      this.horScrollBar = paramComponent;
    else if ("VerScrollBar".equals(paramString))
      this.verScrollBar = paramComponent;
  }

  public void removeLayoutComponent(Component paramComponent)
  {
  }

  public Dimension minimumLayoutSize(Container paramContainer)
  {
    synchronized (paramContainer.getTreeLock())
    {
      Dimension localDimension1 = new Dimension(0, 0);
      Dimension localDimension2 = this.gridRow.getMaximumSize();
      Dimension localDimension3 = this.gridColumn.getMaximumSize();
      Dimension localDimension4 = this.grid.getMaximumSize();
      Dimension localDimension5 = this.verScrollBar.getMaximumSize();
      Dimension localDimension6 = this.horScrollBar.getMaximumSize();
      localDimension1.width += localDimension2.width + localDimension4.width + localDimension5.width;
      localDimension1.height = (localDimension3.height + localDimension4.height + localDimension6.height);
      Insets localInsets = paramContainer.getInsets();
      localDimension1.width += localInsets.left + localInsets.right;
      localDimension1.height += localInsets.top + localInsets.bottom;
      return localDimension1;
    }
  }

  public Dimension preferredLayoutSize(Container paramContainer)
  {
    synchronized (paramContainer.getTreeLock())
    {
      Dimension localDimension1 = new Dimension(0, 0);
      Dimension localDimension2 = this.gridRow.getPreferredSize();
      Dimension localDimension3 = this.gridColumn.getPreferredSize();
      Dimension localDimension4 = this.grid.getPreferredSize();
      Dimension localDimension5 = this.verScrollBar.getPreferredSize();
      Dimension localDimension6 = this.horScrollBar.getPreferredSize();
      localDimension1.width += localDimension2.width + localDimension4.width + localDimension5.width;
      localDimension1.height = (localDimension3.height + localDimension4.height + localDimension6.height);
      Insets localInsets = paramContainer.getInsets();
      localDimension1.width += localInsets.left + localInsets.right;
      localDimension1.height += localInsets.top + localInsets.bottom;
      return localDimension1;
    }
  }

  public void layoutContainer(Container paramContainer)
  {
    synchronized (paramContainer.getTreeLock())
    {
      Insets localInsets = paramContainer.getInsets();
      int i = localInsets.top;
      int j = paramContainer.getHeight() - localInsets.bottom;
      int k = localInsets.left;
      int l = paramContainer.getWidth() - localInsets.right;
      Dimension localDimension1 = this.gridRow.getPreferredSize();
      Dimension localDimension2 = this.gridColumn.getPreferredSize();
      Dimension localDimension3 = this.verScrollBar.getPreferredSize();
      Dimension localDimension4 = this.horScrollBar.getPreferredSize();
      this.gridCorner.setBounds(k, i, localDimension1.width, localDimension2.height);
      this.verScrollBar.setBounds(l - localDimension3.width, 0, localDimension3.width, j - localDimension4.height);
      this.horScrollBar.setBounds(0, j - localDimension4.height, l - localDimension3.width, localDimension4.height);
      this.gridColumn.setBounds(k + localDimension1.width, i, l - localDimension1.width - localDimension3.width, localDimension2.height);
      this.gridRow.setBounds(k, i + localDimension2.height, localDimension1.width, j - localDimension2.height - localDimension4.height);
      this.grid.setBounds(k + localDimension1.width, i + localDimension2.height, l - localDimension1.width - localDimension3.width, j - localDimension2.height - localDimension4.height);
    }
  }

  public String toString()
  {
    return super.getClass().getName();
  }
}